import React from 'react';
import HotRightInfo from "../../../Component/HotRightInfo";
import Consulting from '../../../Server/Consulting';
import URL from '../../../Server/URL';
import MessageUtil from "../../../utils/MessageUtil";

export default class extends React.Component{
    constructor(props){
        super();
        let infos=[];
        let content=props.match.params.content;
        if(content!==undefined){
            Consulting.ConsultingSearch(content,1)
            .then(response=>{
                response.data.forEach(item => {
                    infos.push(
                        <div className="Hot_Content_Info" key={item.consultingId}>
                            <a href={"/HotDetail/"+item.consultingId} target="Layout_MainContainer">
                                <HotRightInfo src={URL.GetURL(item.consultingShowImg)} 
                                    type={item.consultingType} text={item.consultingTitle} 
                                    subtext={item.consultingContent} time={item.consultingTime}/>
                            </a>
                        </div>
                    );
                });
                this.setState({
                    infos
                },()=>{
                    MessageUtil.ChangeHeight();
                });
            });
        }
        else{
            Consulting.SelectListConsulting(1)
            .then(response=>{
                response.data.forEach(item => {
                    infos.push(
                        <div className="Hot_Content_Info" key={item.consultingId}>
                            <a href={"/HotDetail/"+item.consultingId} target="Layout_MainContainer">
                                <HotRightInfo src={URL.GetURL(item.consultingShowImg)} 
                                    type={item.consultingType} text={item.consultingTitle} 
                                    subtext={item.consultingContent} time={item.consultingTime}/>
                            </a>
                        </div>
                    );
                });
                this.setState({
                    infos
                },()=>{
                    MessageUtil.ChangeHeight();
                });
                console.log(response)
            },reject=>{
    
            });
        }
        
        this.state={
            infos
        }
    }
    render(){
        return(
            <div style={{paddingTop:"1rem"}}>
                <div>
                    {this.state.infos}
                </div>
                {/* <div className="Hot_Pagination">
                    <Pagination defaultCurrent={6} total={500} />
                </div> */}
            </div>
        );
    }
}